package com.phiture.erp.stock.web.controller.api;

import com.phiture.erp.stock.api.pojo.resp.ErpStockResp;
import com.phiture.erp.stock.api.service.ErpStockApi;
import com.phiture.erp.stock.core.service.ErpStockService;
import com.phiture.erp.stock.dal.entity.ErpStockDO;
import com.phiture.erp.stock.web.controller.convert.ErpStockConvertMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author YH
 * @date 2025/4/14
 */

@Service
@RequiredArgsConstructor
public class ErpStockApiServiceImpl implements ErpStockApi {
    private final ErpStockService stockService;

    @Override
    public BigDecimal getStockCount(Long materialId) {
        return stockService.getStockCount(null, materialId);
    }

    @Override
    public ErpStockResp getStock(Long materialId, Long warehouseId) {
        ErpStockDO stock = stockService.getStock(materialId, warehouseId);
        return ErpStockConvertMapper.INSTANCE.toErpStockResp(stock);
    }
}
